package cn.net.gemai.springboot_swagger.controller;

import cn.net.gemai.springboot_swagger.entity.User;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MyController {

    @ApiOperation("Say Hello 接口")
    @GetMapping({"hello"})
    public String hello(){
        return "hello world !";
    }

    @ApiOperation(value = "获取用户信息",httpMethod = "GET", response = String.class, notes = "接口发布说明")
    @ApiImplicitParams({
            @ApiImplicitParam(name="name",value="用户姓名",required=true),
            @ApiImplicitParam(name="age",value="年龄",required=false,dataType="Integer")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功"),
            @ApiResponse(code=400,message="请求参数没填好"),
            @ApiResponse(code=401,message="无权限"),
            @ApiResponse(code=403,message="禁止访问"),
            @ApiResponse(code=404,message="请求路径没有或页面跳转路径不对")
    })
    @GetMapping({"user"})
    public String getUser(String name, int age){
        User user = new User();
        user.setName(name);
        user.setAge(age);
        return user.toString();
    }
}
